﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
using XJE.Scheduler.IService;
using XJay.Scheduler.Model.Birthday.Export;
using XJay.Scheduler.Model.Birthday.Import;
using XJay.Scheduler.Model.Page;

namespace XJay.Scheduler.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class BirthdayController : BaseController
    {
        private readonly IBirthdayServer _birthdayServer;

        public BirthdayController(IBirthdayServer birthdayServer)
        {
            _birthdayServer = birthdayServer;
        }
        /// <summary>
        /// 查看生日列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<QueryBirthdayDto>> QueryBirthday([FromQuery] PageParam param)
        {
            return await _birthdayServer.QueryBirthdayAsync(param, UserInfo);
        }
        /// <summary>
        /// 添加生日信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<bool> AddBirthday(AddBirthdayParam param)
        {
            return await _birthdayServer.AddBirthdayAsync(param, UserInfo);
        }
        /// <summary>
        /// 删除生日信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("{id}")]
        public async Task<bool> DeleteBirthday(int id)
        {
            return await _birthdayServer.DeleteBirthdayAsync(id, UserInfo);
        }
    }
}
